const path = require('path')

module.exports = plop => {
  plop.setGenerator('newComponents', {
    description: 'create a custom component',
    // 命令行问题
    prompts: [{
      type: 'input',
      name: 'name',
      message: 'component name',
      default: 'MyComponent'
    }],
    actions: [
      {
        type: 'add',
        path: 'packages/{{name}}/src/{{name}}.vue',
        templateFile: path.join(__dirname, '../templates/newComponent/src/component.hbs')
      },
      {
        type: 'add',
        path: 'packages/{{name}}/__tests__/{{name}}.test.js',
        templateFile: path.join(__dirname, '../../plop/templates/newComponent/__tests__/component.test.hbs')
      },
      {
        type: 'add',
        path: 'packages/{{name}}/stories/{{name}}.stories.js',
        templateFile: path.join(__dirname, '../../plop/templates/newComponent/stories/component.stories.hbs')
      },
      {
        type: 'add',
        path: 'packages/{{name}}/stories/conf.js',
        templateFile: path.join(__dirname, '../../plop/templates/newComponent/stories/conf.js')
      },
      {
        type: 'add',
        path: 'packages/{{name}}/index.ts',
        templateFile: path.join(__dirname, '../../plop/templates/newComponent/index.hbs')
      },
      {
        type: 'add',
        path: 'packages/{{name}}/LICENSE',
        templateFile: path.join(__dirname, '../../plop/templates/newComponent/LICENSE')
      },
      {
        type: 'add',
        path: 'packages/{{name}}/package.json',
        templateFile: path.join(__dirname, '../../plop/templates/newComponent/package.hbs')
      },
      {
        type: 'add',
        path: 'packages/{{name}}/README.md',
        templateFile: path.join(__dirname, '../../plop/templates/newComponent/README.hbs')
      }
    ]
  })
}
